package com.happyfamily.springboot.crowdsourcingplatform.controller.pan;

import com.happyfamily.springboot.crowdsourcingplatform.annotation.OperationLogDetail;
import com.happyfamily.springboot.crowdsourcingplatform.base.result.PageTableRequest;
import com.happyfamily.springboot.crowdsourcingplatform.base.result.ResponseCode;
import com.happyfamily.springboot.crowdsourcingplatform.base.result.Results;
import com.happyfamily.springboot.crowdsourcingplatform.enums.OperationType;
import com.happyfamily.springboot.crowdsourcingplatform.enums.OperationUnit;
import com.happyfamily.springboot.crowdsourcingplatform.model.LastestInfomation;
import com.happyfamily.springboot.crowdsourcingplatform.model.Orders;
import com.happyfamily.springboot.crowdsourcingplatform.model.SysUser;
import com.happyfamily.springboot.crowdsourcingplatform.service.pan.SuccessCaseService;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * @Author Administrator
 * @create 2020/02/29 12:11
 */
@Controller
@RequestMapping("/api-back/")
public class SuccessCaseController
{

	@Autowired
	private SuccessCaseService successCaseService;


	/**
	 * 获取订单状态为已完成的数据
	 * @param request
	 * @return
	 */
	@GetMapping("successList")
	@ResponseBody
	@ApiOperation(value = "获得订单状态为已完成", notes = "查询类型是订单状态为已完成", httpMethod = "GET", response = Results.class)
	@OperationLogDetail(detail = "获得订单状态为已完成", level = 1, operationUnit = OperationUnit.USER, operationType = OperationType.SELECT)
	public Results<Orders> getAllNeedsByPage(PageTableRequest request)
	{
		request.countOffset();
		return successCaseService.getAllOrdesByPage(request.getOffset(), request.getLimit());
	}


	/**
	 * 修改订单是否为成功案例
	 * @param
	 * @return
	 */
	@GetMapping("updates")
	@ResponseBody
	@ApiOperation(value = "修改订单为成功案例", notes = "修改类型为订单id", httpMethod = "GET", response = Results.class)
	@OperationLogDetail(detail = "修改订单为成功案例", level = 2, operationUnit = OperationUnit.USER, operationType = OperationType.SELECT)
	public Results updatesTate(@Param("oid") Integer oid, @Param("successcase")Integer successcase)
	{
		//根据订单id修改成功案例数据
		successCaseService.updateSuccessCase(oid,successcase);
		return Results.failure(ResponseCode.UPDATE_ORDERS.getCode(),ResponseCode.UPDATE_ORDERS.getMessage());
	}













}





